import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ViewController, AlertController } from 'ionic-angular';
import {AppConfig} from "../../app/app.config";

/**
 * Generated class for the ModifyTextPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-modify-age',
  templateUrl: 'modify-age.html',
})
export class ModifyAgePage {

  textData:any;
  text:any;

  constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public viewCtrl:ViewController,
    public alertCtrl:AlertController) {
    this.textData = navParams.get('text');
  }

  ionViewDidEnter() {
    // console.log('ionViewDidLoad ModifyTextPage');
    AppConfig.viewCtrl = this.viewCtrl;
  }

  dismiss(){
    this.viewCtrl.dismiss();
  }

  saveDismiss(){
    if(!isNaN(this.text)){
      this.viewCtrl.dismiss(this.text);
    }else{
      this.showAlert();
    }
  }


  showAlert() {
    let alert = this.alertCtrl.create({
      title: '填写错误!',
      subTitle: '不要调皮，请输入数字！',
      buttons: ['OK']
    });
    alert.present();
  }


}
